<template>
	<div class="c">
		<h1>我是C组件</h1>
		<h4>{{username}}</h4>
		<D></D>
	</div>
</template>

<script>
	import D from './D.vue'

	export default {
		name:'C',
		components:{D},
		data() {
			return {
				username:''
			}
		},
		mounted() {
			this.$bus.$on('get-username',(value)=>{
				this.username = value
			})
		},
		beforeDestroy() {
			this.$bus.$off('get-username')
		},
	}
</script>

<style scoped>
	.c{
		background-color: orange;
		padding: 20px;
	}
</style>